/*
               File: PrcCvrtCPFNumeric
        Description: Prc Cvrt CPFNumeric
             Author: GeneXus C# Generator version 10_2_5-78484
       Generated on: 6/6/2014 9:52:41.69
       Program type: Callable routine
          Main DBMS: sqlserver
*/
using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.Procedure;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Threading;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
   public class prccvrtcpfnumeric : GXProcedure
   {
      public prccvrtcpfnumeric( )
      {
         context = new GxContext(  );
         DataStoreUtil.LoadDataStores( context);
         IsMain = true;
         context.SetDefaultTheme("GeneXusXEv2");
      }

      public prccvrtcpfnumeric( IGxContext context )
      {
         this.context = context;
         IsMain = false;
      }

      public void release( )
      {
      }

      public void execute( String aP0_OldCPF ,
                           out long aP1_NewCPF )
      {
         this.AV10OldCPF = aP0_OldCPF;
         this.AV8NewCPF = 0 ;
         initialize();
         executePrivate();
         aP1_NewCPF=this.AV8NewCPF;
      }

      public long executeUdp( String aP0_OldCPF )
      {
         this.AV10OldCPF = aP0_OldCPF;
         this.AV8NewCPF = 0 ;
         initialize();
         executePrivate();
         aP1_NewCPF=this.AV8NewCPF;
         return AV8NewCPF ;
      }

      public void executeSubmit( String aP0_OldCPF ,
                                 out long aP1_NewCPF )
      {
         prccvrtcpfnumeric objprccvrtcpfnumeric;
         objprccvrtcpfnumeric = new prccvrtcpfnumeric();
         objprccvrtcpfnumeric.AV10OldCPF = aP0_OldCPF;
         objprccvrtcpfnumeric.AV8NewCPF = 0 ;
         objprccvrtcpfnumeric.context.SetSubmitInitialConfig(context);
         objprccvrtcpfnumeric.initialize();
         ThreadPool.QueueUserWorkItem( new WaitCallback( executePrivateCatch ),objprccvrtcpfnumeric);
         aP1_NewCPF=this.AV8NewCPF;
      }

      void executePrivateCatch( object stateInfo )
      {
         try
         {
            ((prccvrtcpfnumeric)stateInfo).executePrivate();
         }
         catch ( Exception e )
         {
            GXUtil.SaveToEventLog( "Design", e);
            throw e ;
         }
      }

      void executePrivate( )
      {
         /* GeneXus formulas */
         /* Output device settings */
         AV11x = 1;
         while ( AV11x <= StringUtil.Len( AV10OldCPF) )
         {
            AV9NewCPFChar = AV9NewCPFChar + StringUtil.Substring( AV10OldCPF, AV11x, 1);
            if ( ( StringUtil.StrCmp(StringUtil.Substring( AV10OldCPF, AV11x, 1), ".") == 0 ) || ( StringUtil.StrCmp(StringUtil.Substring( AV10OldCPF, AV11x, 1), "-") == 0 ) )
            {
               AV9NewCPFChar = StringUtil.Substring( AV9NewCPFChar, 1, StringUtil.Len( AV9NewCPFChar)-1);
            }
            AV11x = (short)(AV11x+1);
         }
         AV8NewCPF = (long)(NumberUtil.Val( AV9NewCPFChar, "."));
         this.cleanup();
      }

      public void cleanup( )
      {
         CloseOpenCursors();
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
         exitApplication();
      }

      protected void CloseOpenCursors( )
      {
      }

      public override void initialize( )
      {
         AV9NewCPFChar = "";
         /* GeneXus formulas. */
         context.Gx_err = 0;
      }

      private short AV11x ;
      private long AV8NewCPF ;
      private String AV10OldCPF ;
      private String AV9NewCPFChar ;
      private long aP1_NewCPF ;
   }

}
